# #设计类
# class Student:
#     name=None
#     age=None
#     gender=None
#
# #创建一个对象
# stu=Student()
# #对对象进行赋值
# stu.age=18
# stu.gender="男"
# stu.name="江凡"
# print(stu.name)


# 魔术方法
# 1.构造方法
class Student:
    name = None
    age = None
    gender = None

    def __init__(self, name, age, gender):
        self.name = name
        self.age = age
        self.gender = gender
        print("创建一个类对象")


stu = Student("江凡", 18, "男")
print(stu.name)
print("字符串方法:")


class Student1:
    name = None
    age = None
    gender = None

    def __init__(self, name, age, gender):
        self.name = name
        self.age = age
        self.gender = gender
        print("创建一个类对象")

    def __str__(self):
        return f"name={self.name},age={self.age},gender={self.gender}"



stu1 = Student1("江凡", 18, "男")
stu2 = Student1("江成", 29, "男")
print(stu1)
print(stu2)



